package com.huike.game.adapter;

import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.huike.game.R;
import com.huike.game.qingqing.Bena22.DataBean;

import java.util.ArrayList;

public class MyAdapter extends BaseAdapter {

    ArrayList<DataBean> list=null;


    public MyAdapter(ArrayList<DataBean> data){
        list = data;



    }

        @Override
        public int getCount() {
            return list.size();
        }

        @Override
        public Object getItem(int position) {
            return list.get(position);
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            ViewHolder holder = null;
            if (convertView == null) {
                // 第一次加载创建View，其余复用 View
                convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.itemlist, null);
                holder = new ViewHolder();


                holder.textView = convertView.findViewById(R.id.tv1);
                holder.imageView=convertView.findViewById(R.id.im_1);
                DataBean dataBean = list.get(position);
                Log.e("aaa", "getView: "+ list.get(position));




                // 打标签
                convertView.setTag(holder);

            } else {
                // 从标签中获取数据
                holder = (ViewHolder) convertView.getTag();
            }
            holder.textView.setText((CharSequence) list.get(position));

            return convertView;
        }

    class ViewHolder {
        TextView textView;
        ImageView imageView;
    }

}
